/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.aptech.entities;

import java.io.Serializable;
import java.util.List;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Winner
 */
@Entity
@Table(name = "tblProject")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TblProject.findAll", query = "SELECT t FROM TblProject t"),
    @NamedQuery(name = "TblProject.findByPrID", query = "SELECT t FROM TblProject t WHERE t.prID = :prID"),
    @NamedQuery(name = "TblProject.findByPrState", query = "SELECT t FROM TblProject t WHERE t.prState = :prState"),
    @NamedQuery(name = "TblProject.findByPdImageURL", query = "SELECT t FROM TblProject t WHERE t.pdImageURL = :pdImageURL"),
    @NamedQuery(name = "TblProject.findByPrCreated", query = "SELECT t FROM TblProject t WHERE t.prCreated = :prCreated"),
    @NamedQuery(name = "TblProject.findByPrCompleted", query = "SELECT t FROM TblProject t WHERE t.prCompleted = :prCompleted"),
    @NamedQuery(name = "TblProject.findByPrEnable", query = "SELECT t FROM TblProject t WHERE t.prEnable = :prEnable"),
    @NamedQuery(name = "TblProject.findByManager", query = "SELECT t FROM TblProject t WHERE t.mnID.mnID = :mnID"),
    @NamedQuery(name = "TblProject.findByOdID", query = "SELECT t FROM TblProject t WHERE t.odID.odID = :odID"),
    @NamedQuery(name = "TblProject.findByPrState1", query = "SELECT t FROM TblProject t WHERE t.prState = 2"),
    @NamedQuery(name = "TblProject.findByPrState2", query = "SELECT t FROM TblProject t WHERE t.prState = 5"),
    @NamedQuery(name = "TblProject.findByDatePrCreated", query = "SELECT t FROM TblProject t WHERE t.prCreated >= :dateStart AND t.prCreated <= :dateEnd ORDER BY t.prCreated DESC"),
    @NamedQuery(name = "TblProject.findByDatePrCompleted", query = "SELECT t FROM TblProject t WHERE t.prCompleted >= :dateStart AND t.prCompleted <= :dateEnd ORDER BY t.prCompleted DESC")})
public class TblProject implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "prID")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer prID;
    @Column(name = "prState")
    private Integer prState;
    @Size(max = 200)
    @Column(name = "pdImageURL")
    private String pdImageURL;
    @Basic(optional = false)
    @NotNull
    @Column(name = "prCreated")
    @Temporal(TemporalType.TIMESTAMP)
    private Date prCreated;
    @Column(name = "prCompleted")
    @Temporal(TemporalType.TIMESTAMP)
    private Date prCompleted;
    @Column(name = "prEnable")
    private Boolean prEnable;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tblProject")
    private List<TblProjectDetail> tblProjectDetailList;
    @JoinColumn(name = "odID", referencedColumnName = "odID")
    @ManyToOne
    private TblOrder odID;
    @JoinColumn(name = "mnID", referencedColumnName = "mnID")
    @ManyToOne
    private TblManager mnID;

    public TblProject() {
    }

    public TblProject(Integer prState, String pdImageURL, Date prCreated, Date prCompleted, Boolean prEnable, TblOrder odID, TblManager mnID) {
        this.prState = prState;
        this.pdImageURL = pdImageURL;
        this.prCreated = prCreated;
        this.prCompleted = prCompleted;
        this.prEnable = prEnable;
        this.odID = odID;
        this.mnID = mnID;
    }

    public TblProject(Integer prID) {
        this.prID = prID;
    }

    public TblProject(Integer prID, Date prCreated) {
        this.prID = prID;
        this.prCreated = prCreated;
    }

    public Integer getPrID() {
        return prID;
    }

    public void setPrID(Integer prID) {
        this.prID = prID;
    }

    public Integer getPrState() {
        return prState;
    }

    public void setPrState(Integer prState) {
        this.prState = prState;
    }

    public String getPdImageURL() {
        return pdImageURL;
    }

    public void setPdImageURL(String pdImageURL) {
        this.pdImageURL = pdImageURL;
    }

    public Date getPrCreated() {
        return prCreated;
    }

    public void setPrCreated(Date prCreated) {
        this.prCreated = prCreated;
    }

    public Date getPrCompleted() {
        return prCompleted;
    }

    public void setPrCompleted(Date prCompleted) {
        this.prCompleted = prCompleted;
    }

    public Boolean getPrEnable() {
        return prEnable;
    }

    public void setPrEnable(Boolean prEnable) {
        this.prEnable = prEnable;
    }

    @XmlTransient
    public List<TblProjectDetail> getTblProjectDetailList() {
        return tblProjectDetailList;
    }

    public void setTblProjectDetailList(List<TblProjectDetail> tblProjectDetailList) {
        this.tblProjectDetailList = tblProjectDetailList;
    }

    public TblOrder getOdID() {
        return odID;
    }

    public void setOdID(TblOrder odID) {
        this.odID = odID;
    }

    public TblManager getMnID() {
        return mnID;
    }

    public void setMnID(TblManager mnID) {
        this.mnID = mnID;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (prID != null ? prID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TblProject)) {
            return false;
        }
        TblProject other = (TblProject) object;
        if ((this.prID == null && other.prID != null) || (this.prID != null && !this.prID.equals(other.prID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        // return "com.aptech.entities.TblProject[ prID=" + prID + " ]";
        return prID.toString();
    }
}
